using Sage.Http.Options;
using System;
using System.Collections.Generic;

namespace Sage.Http.Configuration
{
    /// <summary>
    /// HTTP客户端全局配置
    /// </summary>
    public static class HttpClientGlobalConfig
    {
        private static RetryOptions _defaultRetryOptions = new RetryOptions();
        private static CircuitBreakerOptions _defaultCircuitBreakerOptions = new CircuitBreakerOptions();
        private static LoggingOptions _defaultLoggingOptions = new LoggingOptions();
        private static RateLimitOptions _defaultRateLimitOptions = new RateLimitOptions();
        
        /// <summary>
        /// 配置默认重试选项
        /// </summary>
        public static void ConfigureRetry(Action<RetryOptions> configure)
        {
            configure?.Invoke(_defaultRetryOptions);
        }
        
        /// <summary>
        /// 配置默认熔断选项
        /// </summary>
        public static void ConfigureCircuitBreaker(Action<CircuitBreakerOptions> configure)
        {
            configure?.Invoke(_defaultCircuitBreakerOptions);
        }
        
        /// <summary>
        /// 配置默认日志选项
        /// </summary>
        public static void ConfigureLogging(Action<LoggingOptions> configure)
        {
            configure?.Invoke(_defaultLoggingOptions);
        }
        
        /// <summary>
        /// 配置默认限流选项
        /// </summary>
        public static void ConfigureRateLimit(Action<RateLimitOptions> configure)
        {
            configure?.Invoke(_defaultRateLimitOptions);
        }
        
        /// <summary>
        /// 获取默认重试选项
        /// </summary>
        public static RetryOptions GetDefaultRetryOptions() => _defaultRetryOptions.Clone();
        
        /// <summary>
        /// 获取默认熔断选项
        /// </summary>
        public static CircuitBreakerOptions GetDefaultCircuitBreakerOptions() => _defaultCircuitBreakerOptions.Clone();
        
        /// <summary>
        /// 获取默认日志选项
        /// </summary>
        public static LoggingOptions GetDefaultLoggingOptions() => _defaultLoggingOptions.Clone();
        
        /// <summary>
        /// 获取默认限流选项
        /// </summary>
        public static RateLimitOptions GetDefaultRateLimitOptions() => _defaultRateLimitOptions.Clone();
    }
}